package com.foreknow.test;

import java.util.*;

public class ListExample {
    public static void main(String[] args) {
        List<Map<String,Employee>> list = new ArrayList<>();
        Map<String,Employee> map1 = new HashMap<>();
        Employee e1 = new Employee();
        e1.setEid(101);
        e1.setName("fender");
        Employee e2 = new Employee();
        e2.setEid(102);
        e2.setName("gibson");
        //将以上两个员工保存到map1中
        map1.put("e1",e1);
        map1.put("e2",e2);
        Map<String,Employee> map2 = new HashMap<>();
        Employee e3 = new Employee();
        e3.setEid(103);
        e3.setName("fender3");
        Employee e4 = new Employee();
        e4.setEid(104);
        e4.setName("gibson4");
        //将以上两个员工保存到map1中
        map2.put("e3",e3);
        map2.put("e4",e4);
        //将map1和map2保存到List容器中
        list.add(map1);
        list.add(map2);

        Iterator<Map<String,Employee>> it = list.iterator();
        while (it.hasNext()) {
            Map<String,Employee> map = it.next();
            Set<Map.Entry<String,Employee>> set = map.entrySet();
            Iterator<Map.Entry<String,Employee>> iterator = set.iterator();
            while (iterator.hasNext()) {
                Map.Entry<String,Employee> entry = iterator.next();
                String key = entry.getKey();
                Employee employee = entry.getValue();
                System.out.println(key + " " + employee.getName());
            }
        }



    }
}
